<template>
	<view class="index-main">
	   <view v-if="zb" class="top-b">
	   	<view style="margin-bottom: 5px;">
	   		{{zb.xiangmumingcheng}}
	   	</view>
		<view class="display-flex ">
			<view class="zbgg-t">
				中标公告
			</view>
			<view style="margin-left: 10px;color: #afafaf;">
				{{zb.fabushijian}}
			</view>
		</view>
		<view class="zb-de display-flex display-flex-column">
			<view class="display-flex mb-5">
				<view class="de-ti">
					项目编号 
				</view>
				<view class="nr-w">
					{{zb.xiangmubianhao}}
				</view>
			</view>
			<view class="display-flex mb-5">
				<view class="de-ti">
					招标单位 
				</view>
				<view class="color-b nr-w">
					{{zb.zhaobiaodanwei}}
				</view>
			</view>
			<view class="display-flex mb-5">
				<view class="de-ti">
					中标供应商
				</view>
				<view class="color-b nr-w">
					{{zb.gongyingshangmingcheng}}
				</view>
			</view>
			<view class="display-flex mb-5">
				<view class="de-ti">
					中标价格
				</view>
				<view class="color-b nr-w">
					{{zb.toubiaojiage}}
				</view>
			</view>
		</view>
	   </view>
	   <view class="zbnr">
	   	<view class="conter">
			<view style="text-align: center;margin-bottom: 10px;">
				招标内容
			</view>
	   		<jyf-parser :html="zb.toubiaoxiangqing" ref="article" :tag-style="tagStyle"></jyf-parser>
	   	</view>
	   </view>
	 
	
	</view>
</template>

<script>
	import {mapGetters} from 'vuex';
	import { toLogin} from '@/libs/login.js';
	import { zhongbiaogonggaoDetail , queryToubiao, storeupSave, queryShoucang, storeupcancelsave} from '@/api/api.js';
	import jyfParser from '@/components/jyf-parser/jyf-parser.vue'
export default {
	computed: mapGetters(['isLogin','userInfo']),
	
	components:{
		jyfParser
	},
	data() {
		return {
			id: '',
			zb: '',
			tagStyle: {
				img: 'width:100%;display:block;',
				table: 'width:100%',
				video: 'width:100%'
			},
			isToubiao: false,
			isShoucang: false,
		};
	},
	onShow() {
		
	},
	onReady() {

		
	},

	onLoad(options) {
		if(!options.id){
			this.$u.toast("参数缺失");
			uni.navigateBack();
			return;
		}
		this.id = options.id
		if(this.id){
			this.getDetail()
		}
	},
	onReachBottom(){
	},
	onShareAppMessage(obj) {
        if (obj.from === 'button') {// 来自页面内分享按钮
			var data = obj.target.dataset;
		}
		return {
			title: '邀请您一起参与招标',
			 path: 'pages/zb_detail/index?id='+data.dz_id,
		}
	},
	methods: {
		shouchang(){
			if(!this.isLogin){
				toLogin()
			} else {
				var data = {
					refid: this.zb.id,
					tablename: 'zhaobiaoxiangmu',
					name:  this.zb.xiangmumingcheng,
					picture: this.zb.fengmian,
					type: 1,
					inteltype: this.zb.zhaobiaofenlei,
				}
				storeupSave(data).then(res => {
					this.$u.toast("收藏成功")
					this.isShoucang = true;
				}).catch(err => {
				console.log(11,err)
				this.$u.toast(err)
				uni.hideLoading()
			})
			}
		},
		cancelshouchang(){
			
			var data = {
				refid: this.zb.id,
				tablename: 'zhaobiaoxiangmu',
				name:  this.zb.xiangmumingcheng,
				picture: this.zb.fengmian,
				type: 1,
				inteltype: this.zb.zhaobiaofenlei,
			}
			storeupcancelsave(data).then(res => {
				this.$u.toast("取消成功");
				this.isShoucang = false;
			}).catch(err => {
				console.log(11,err)
				this.$u.toast(err)
				uni.hideLoading()
			})
		},
		gotoubiao(){
			if(!this.isLogin){
				toLogin()
			} else{
				if(this.userInfo.iscom){
					console.log("已经完成")
					
					//可以进行投标
					this.toubiao()
				} else{
					
					uni.showModal({
						title: '温馨提示',
						content: '您尚未完善供应商信息，完善信息后可投标！',
						success(res) {
							if (res.confirm) {
								// 新的版本已经下载好，调用 applyUpdate 应用新版本并重启
								uni.navigateTo({
									url:'/pages/wanshan/index'
								})
							}
						}
					});
					
				}
			}
		},
		toubiao(){
			uni.navigateTo({
				url:'/pages/toubiao/index?id='+this.id
			})
		},
		chaxuntb(){
			queryToubiao({'xiangmubianhao': this.zb.xiangmubianhao}).then(res => {
				this.isToubiao = res.data?res.data:false
			})
		},
		chaxunsc(){
			queryShoucang({'refid': this.zb.id}).then(res => {
				this.isShoucang = res.data?res.data:false
			})
		},
		getDetail(){
			uni.showLoading({
				title: '加载中'
			});
			zhongbiaogonggaoDetail(this.id).then(res => {
				uni.hideLoading()
				this.zb= res.data
				// if(this.isLogin){
				// 	this.chaxuntb()
				// 	this.chaxunsc()
				// }
			}).catch(err => {
				console.log(11,err)
				this.$u.toast(err)
				uni.hideLoading()
			})
		},
	
	}
};
</script>

<style lang="scss" >
	page{
		background-color: #f7f7f7 !important;
	}
	
	.top-b{
		background-color: #ffffff;
		padding: 15px 10px 10px 10px;
		margin-bottom: 10px;
	}
	.zbgg-t{
		background: #f9f7f3;
		padding: 2px 4px;
		border-radius: 2px;
		color: #ff7b3c;
		font-size: 12px;
	}
	.zb-de{
		margin-top: 10px;
		background-color: #fafcfd;
		padding: 12px;
	}
	.de-ti{
		width: 120px;
		color: #c2c2c2;
	}
	.zbnr{
		background-color: #ffffff;
		padding: 15px 10px 10px 10px;
	}
	 .conter {
		display: block;
		padding-bottom: 130rpx;
	}

	.conter img {
		display: block;
	}
	
	.navfooter{
		color: #666;
		background-color: #fff;
		bottom: 0;
		box-shadow: 0rpx -2rpx 8rpx rgba(0,0,0,.1);
		display: flex;
		font-size: 32rpx;
		justify-content: space-between;
		left: 0;
		padding-bottom: env(safe-area-inset-bottom);
		position: fixed;
		text-align: center;
		width: 100%;
		z-index: 100;
	}
	.nav-item {
	    flex-grow: 1;
	    position: relative;
	}
	.nav-icon{
		padding-top: 16rpx;
		font-size: 20px;
		color: #000;
		padding-bottom: 8rpx;
	}
	.nav-text{
		color: #666;
		font-size: 20rpx;
		line-height: 28rpx;
		padding-bottom: 12rpx;
	}
	.safe-height{
		height: 140rpx;
		padding-bottom: env(safe-area-inset-bottom);
	}
	.buy-btn {
	    background: #007AFF;
	    border-radius: 50rpx;
	    color: #fff;
	    flex: 0 0 200rpx;
	    font-size: 26rpx;
	    font-weight: 600;
	    height: 70rpx;
	    line-height: 70rpx;
	    margin-right: 30rpx;
	    text-align: center;
	}
	.nr-w{
		width: 70%;
	}
</style>
